import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;



public class Tramsaction {
    PlatformTransactionManager platformTransactionManager=new JdbcTransactionManager();

   public void tran(){
       //事务开始
       TransactionStatus status = platformTransactionManager.getTransaction(new DefaultTransactionDefinition());
       DefaultTransactionDefinition definition=new DefaultTransactionDefinition();



       try{

           //业务代码·······



           //提交事务
           platformTransactionManager.commit(status);
       }catch (RuntimeException e){
          //回滚事务
           platformTransactionManager.rollback(status);
       }
   }

   @Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRES_NEW)
   public void function1(){
       //业务代码······

   }
}




class A {
@Transactional(propagation=Propagation.xxx)
public void aMethod() {
//业务代码
        B b = new B();
        b.bMethod();
    }
}

class B {

@Transactional(propagation=Propagation.xxx)
public void bMethod() {
        //业务代码
        }
}


